import 'dart:async';

import 'package:flutter/material.dart';

class MyDialog extends Dialog {
  _showTimer(context) {
    Timer.periodic(Duration(milliseconds: 3000), (t) {
      Navigator.pop(context);
      t.cancel();
    });
  }

  @override
  Widget build(BuildContext context) {
    _showTimer(context);
    return Material(
      type: MaterialType.transparency,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Container(
            height: 300,
            width: 300,
            color: Colors.white,
            child: Column(
              children: [
                SizedBox(height: 10),
                Padding(
                    padding: EdgeInsets.only(right: 10),
                    child: Stack(
                      children: [
                        Align(
                          child: Text(
                            '我是标题',
                            textAlign: TextAlign.center,
                            style: TextStyle(
                              fontWeight: FontWeight.w600,
                              fontSize: 16,
                            ),
                          ),
                        ),
                        Align(
                          child: InkWell(
                            child: Icon(
                              Icons.close,
                              color: Colors.black12,
                            ),
                            onTap: () {
                              Navigator.pop(context);
                            },
                          ),
                          alignment: Alignment.topRight,
                        )
                      ],
                    )),
                SizedBox(height: 5),
                Divider(),
                Container(
                  width: double.infinity,
                  padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
                  child: Text(
                    '我是内容',
                    style: TextStyle(color: Colors.black87),
                  ),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
